package JUC;

import org.junit.Test;

import java.sql.Connection;
import java.util.*;

import static MyUtils.MHUtils.*;
import static MyUtils.MHMoban.*;

class A implements Comparable<A>{
    int age;
    String name;
    A(int a, String n){
        age = a;
        name =n;
    }

    @Override
    public int compareTo(A net) {
        return this.age - net.age;
    }
}
public class compare_able_tor {
    @Test
    public void test() {
        A a1 = new A(1, "mh");
        A a2 = new A(2,"ma");
        A a3 = new A(3,"mabhhz");
        //若字典序：ma mabhhz mh
        List<A> list = new ArrayList<>();
        list.add(a1);
        list.add(a2);
        list.add(a3);
        Collections.sort(list);
        System.out.println(list);
    }
}
